/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session;

import entity.Event;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author 7P7
 */
@Stateless
public class EventFacade extends AbstractFacade<Event> {
    @PersistenceContext(unitName = "KSCPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public EventFacade() {
        super(Event.class);
    }
    
    public List<Event> getTopNewNews(){
        Query q =  em.createNamedQuery("Event.topNewNews");
        q.setFirstResult(0);
        q.setMaxResults(5);
        List<Event> evList = q.getResultList();
        return evList;
    }
    
    public List<Event> getTopFreeNews(){
        Query q =  em.createNamedQuery("Event.topFreeNews");
        q.setFirstResult(0);
        q.setMaxResults(5);
        List<Event> evList = q.getResultList();
        return evList;
    }
}
